/*
 * @Descripttion: 
 * @version: 
 * @Author: cc
 * @Date: 2023-05-06 20:55:18
 */
const express = require('express')

const router = express.Router()

const groupRouter = require('../router_handle/group')

//创建群聊
router.post('/creategroup', (req, res) => {
    let data = req.body
    console.log(data);
    groupRouter.createGroup(data, res)
})

//修改群信息
router.post('/updategroup', (req, res) => {
    let data = req.body
    groupRouter.updateGroup(data, res)
})

//获取某个群的群名，群成员，群公告，群头像等等
router.get('/getgroupdetail', (req, res) => {
    let data = req.query
    groupRouter.getGroupDetail(data, res)
})

//删除某个群成员
router.post('/deletegroupmember', (req, res) => {
    let data = req.body
    groupRouter.deleteGroupUser(data, res)
})

//邀请用户加入某群聊
router.post('/addgroup', (req, res) => {
    let data = req.body
    let obj = {
        groupid: data.groupid,
        userid: data.userid,
        time: new Date(),
        lastTime: new Date()
    }
    groupRouter.insertGroupUser(obj, res)
})

router.post('/outGroup', (req, res) => {
    let data = req.body
    groupRouter.outGroup(data, res)
})

//获取群成员信息
router.get('/getgroupmember', (req, res) => {
    let gid = req.query.gid
    groupRouter.getGroupMember(gid, res)
})


//修改某个用户在某群的群内名 
router.post('/updateUserMarkNameInGroup', (req, res) => {
    let data = req.body
    groupRouter.updateUserMarkNameInGroup(data, res)
})

module.exports = router